package com.xbongbong.paas.config.enums;

import com.xbongbong.paas.enums.FieldTypeEnum;
import lombok.Getter;

import java.util.HashSet;
import java.util.Set;

/**
 * 工作流可以作为条件的字段
 * @author 吴峰
 * @date 2021/05/25 17:27
 */
@Getter
public enum WorkflowConditionEnum {

    // 单行文本
    TEXT(FieldTypeEnum.TEXT),
    TEXTAREA(FieldTypeEnum.TEXTAREA),
    //数字
    NUM(FieldTypeEnum.NUM),
    // 下拉框:combo
    COMBO(FieldTypeEnum.COMBO),
    // DateTimeEnum
    DATETIME(FieldTypeEnum.DATETIME),
    // radiogroup 单选按钮
    RADIO_GROUP(FieldTypeEnum.RADIO_GROUP),
    //  下拉框复选：combocheck
    COMBO_CHECK(FieldTypeEnum.COMBO_CHECK),
    //  复现框
    CHECKBOX_GROUP(FieldTypeEnum.CHECKBOX_GROUP),
    // 用户单选
    USER(FieldTypeEnum.USER),
    // 标签
    LABEL(FieldTypeEnum.LABEL),
    // 用户多选
    USER_GROUP(FieldTypeEnum.USER_GROUP),
    // 部门单选,
    DEPT(FieldTypeEnum.DEPT),
    // 部门多选
    DEPT_GROUP(FieldTypeEnum.DEPT_GROUP),
    // 创建人,
    CREATORID(FieldTypeEnum.CREATORID),
    //
    DEPARTMENTID(FieldTypeEnum.DEPARTMENTID),
    OWNERID(FieldTypeEnum.OWNERID),
    COUSERID(FieldTypeEnum.COUSERID),
    // 发起部门
    CREATOR_DEPT(FieldTypeEnum.CREATOR_DEPT),
    ADDTIME(FieldTypeEnum.ADDTIME),
    UPDATETIME(FieldTypeEnum.UPDATETIME),


    ;

    private FieldTypeEnum fieldTypeEnum;


    public static final Set<Integer> conditionSet = initCondition();

    WorkflowConditionEnum(FieldTypeEnum fieldTypeEnum) {
        this.fieldTypeEnum = fieldTypeEnum;
    }


    public static Set<Integer> initCondition() {

        Set<Integer> set = new HashSet<>();
        for(WorkflowConditionEnum workflowConditionEnum: WorkflowConditionEnum.values()) {
            set.add(workflowConditionEnum.getFieldTypeEnum().getType());
        }
        return set;
    }
}
